<?php
/*function curl_file_get_contents($durl){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $durl);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_);
    curl_setopt($ch, CURLOPT_REFERER,_REFERER_);
    curl_setopt($ch, CURLOPT_REFERER, "http:\/\/www.baidu.com\/");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
    $r = curl_exec($ch);
    curl_close($ch);
    return $r;
}*/

function curl_file_get_contents($durl){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $durl);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:8.8.8.8', 'CLIENT-IP:8.8.8.8'));  //构造IP
    curl_setopt($ch, CURLOPT_REFERER,_REFERER_);
    //curl_setopt($ch, CURLOPT_REFERER, "http:\/\/www.google.com\/");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
    
    // curl_setopt($ch, CURLOPT_URL,$url);
    /*curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postArray); */
    
    
    $r = curl_exec($ch);
    curl_close($ch);
    return $r;
}

class runtime
{ 
    var $StartTime = 0; 
    var $StopTime = 0; 

    function get_microtime() 
    { 
        list($usec, $sec) = explode(' ', microtime()); 
        return ((float)$usec + (float)$sec); 
    }
 
    function start() 
    { 
        $this->StartTime = $this->get_microtime(); 
    }
 
    function stop() 
    { 
        $this->StopTime = $this->get_microtime(); 
    }
 
    function spent() 
    { 
        return round(($this->StopTime - $this->StartTime) * 1000, 1); 
    }
    
}
?>